<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="js/html5.js"></script>
<script type="text/javascript" src="js/respond.min.js"></script>
<script type="text/javascript" src="js/PIE_IE678.js"></script>
<![endif]-->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="css/style.css" />
    <link href="assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/ace.min.css" />
    <link rel="stylesheet" href="Widget/zTree/css/metroStyle/metroStyle.css" type="text/css">
    <link rel="stylesheet" href="assets/css/font-awesome.min.css" />
    <!--[if IE 7]>
		  <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
		<![endif]-->
    <link href="Widget/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <link href="Widget/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
    <link type="text/css" rel="stylesheet" href="css/popup.css" />
    <title>修改商品</title>
</head>

<body>
    <div class="clearfix" id="add_picture">
        <div id="scrollsidebar" class="left_Treeview">
            <div class="show_btn" id="rightArrow"><span></span></div>
            <div class="widget-box side_content">
                <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
                <div class="side_list">
                    <div class="widget-header header-color-green2">
                        <h4 class="lighter smaller">选择产品类型</h4>
                    </div>
                    <div class="widget-body">
                        <div class="widget-main padding-8">
                            <div id="treeDemo" class="ztree"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="page_right_style">
            <div class="type_title">修改商品</div>
            <form action="" method="post" class="form form-horizontal" id="form-article-add">
                <input id="pid" type="hidden" th:value="${productInfo.pid}">
                <input id="idid" type="hidden" th:value="${productInfo.id}">
                <!-- <div class="clearfix cl">
                    <label class="form-label col-2"><span class="c-red">*</span>图片标题：</label>
                    <div class="formControls col-10"><input type="text" class="input-text" value="" placeholder=""
                            id="pictureName" name=""></div>
                </div> -->
                <div class=" clearfix cl">
                    <label class="form-label col-2">产品名称：</label>
                    <div class="formControls col-10"><input type="text" class="input-text" th:value="${productInfo.productName}" placeholder=""
                            id="productName" name=""></div>
                </div>
                <div class=" clearfix cl">

                    <div class="Add_p_s">
                        <label class="form-label col-2">产品编号：</label>
                        <div class="formControls col-2"><input type="text" class="input-text" th:value="${productInfo.productId}" placeholder=""
                                id="productId" name=""></div>
                    </div>
                    <div class="Add_p_s">
                        <label class="form-label col-2">产&nbsp;&nbsp;&nbsp;&nbsp;地：</label>
                        <div class="formControls col-2">
                            <input type="text" class="input-text" th:value="${productInfo.area}" placeholder="" id="areaId" name="">
                        </div>
                    </div>
                    <!-- <div class="Add_p_s">
                        <label class="form-label col-2">材&nbsp;&nbsp;&nbsp;&nbsp;质：</label>
                        <div class="formControls col-2"><input type="text" class="input-text" value="" placeholder=""
                                id="texture" name=""></div>
                    </div> -->
                    <!-- <div class="Add_p_s">
                        <label class="form-label col-2">品&nbsp;&nbsp;&nbsp;&nbsp;牌：</label>
                        <div class="formControls col-2"><input type="text" class="input-text" value="" placeholder=""
                                id="" name=""></div>
                    </div> -->
                    <!-- <div class="Add_p_s">
                        <label class="form-label col-2">产品重量：</label>
                        <div class="formControls col-2"><input type="text" class="input-text" value="" placeholder=""
                                id="weight" name="">kg</div>
                    </div> -->
                    <!-- <div class="Add_p_s">
                        <label class="form-label col-2">单位：</label>
                        <div class="formControls col-2"><span class="select-box">
                                <select class="select">
                                    <option>请选择</option>
                                    <option value="1">件</option>
                                    <option value="2">斤</option>
                                    <option value="3">KG</option>
                                    <option value="4">吨</option>
                                    <option value="5">套</option>
                                </select>
                            </span></div>
                    </div> -->
                    <div class="Add_p_s">
                        <label class="form-label col-2">展示价格：</label>
                        <div class="formControls col-2"><input type="text" class="input-text" th:value="${productInfo.currentPrice}" placeholder=""
                                id="currentPrice" name="">元</div>
                    </div>
                    <div class="Add_p_s">
                        <label class="form-label col-2">市场价格：</label>
                        <div class="formControls col-2"><input type="text" class="input-text" th:value="${productInfo.originalPrice}" placeholder=""
                                id="originalPrice" name="">元</div>
                    </div>


                </div>

                <!-- <div class="clearfix cl">
                    <label class="form-label col-2">关键词：</label>
                    <div class="formControls col-10">
                        <input type="text" class="input-text" value="" placeholder="" id="keyword" name="">
                    </div>
                </div> -->
                <div class="clearfix cl">
                    <label class="form-label col-2">内容摘要：</label>
                    <div class="formControls col-10">
                        <textarea name="" cols="" rows="" id="text1" class="textarea" placeholder="说点什么...最少输入10个字符"
                            datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！"
                            onKeyUp="textarealength(this,200)">[[${productInfo.content}]]</textarea>  
                        <p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
                    </div>
                </div>

                <!-- <div class="clearfix cl">
                    <label class="form-label col-2">图片上传：</label>
                    <div class="formControls col-10">
                        <div class="uploader-list-container">
                            <div class="queueList">
                                <div id="dndArea" class="placeholder">
                                    <div id="filePicker-2"></div>
                                    <p>或将照片拖到这里，单次最多可选300张</p>
                                </div>
                            </div>
                            <div class="statusBar" style="display:none;">
                                <div class="progress"> <span class="text">0%</span> <span class="percentage"></span>
                                </div>
                                <div class="info"></div>
                                <div class="btns">
                                    <div id="filePicker2"></div>
                                    <div class="uploadBtn">开始上传</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div> -->
                <!-- <div class="clearfix cl">
                    <label class="form-label col-2">详细内容：</label>
                    <div class="formControls col-10">
                        <script id="editor" type="text/plain" style="width:100%;height:400px;"></script>
                    </div>
                </div>
                <div class="clearfix cl">
                    <label class="form-label col-2">允许评论：</label>
                    <div class="formControls col-2 skin-minimal">
                        <div class="check-box" style="margin-top: 9px"><input type="checkbox" id="checkbox-1"><label
                                for="checkbox-1">&nbsp;</label></div>
                    </div>
                </div> -->
                <div class="clearfix cl">
                    <div class="Button_operation">
                        <!-- <button id="save" onClick="article_save_submit();" class="btn btn-primary radius" type="submit"><i class="icon-save "></i>保存并提交审核</button> -->
                        <button id="save" class="btn btn-primary radius" type="button"><i
                                class="icon-save "></i>保存</button>
                        <!-- <button onClick="article_save();" class="btn btn-secondary  btn-warning" type="button"><i
                                class="icon-save"></i>保存草稿</button> -->
                        <button onClick="layer_close();" class="btn btn-default radius"
                            type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!-- </div> -->
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/typeahead-bs2.min.js"></script>
    <script src="assets/layer/layer.js" type="text/javascript"></script>
    <script src="assets/laydate/laydate.js" type="text/javascript"></script>
    <script type="text/javascript" src="Widget/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="Widget/icheck/jquery.icheck.min.js"></script>
    <script type="text/javascript" src="Widget/zTree/js/jquery.ztree.all-3.5.min.js"></script>
    <script type="text/javascript" src="Widget/Validform/5.3.2/Validform.min.js"></script>
    <script type="text/javascript" src="Widget/webuploader/0.1.5/webuploader.min.js"></script>
    <script type="text/javascript" src="Widget/ueditor/1.4.3/ueditor.config.js"></script>
    <script type="text/javascript" src="Widget/ueditor/1.4.3/ueditor.all.min.js"> </script>
    <script type="text/javascript" src="Widget/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
    <script src="js/lrtk.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/H-ui.js"></script>
    <script type="text/javascript" src="js/H-ui.admin.js"></script>
    <script type="text/javascript" src="js/page/popup.js"></script>

    <script>
        $(function () {
            var idid = Number($("#idid").val());
            // console.log($("#pid").val());
            // console.log("idid="+ idid);
            var save = document.getElementById("save");
            var po = new Popup();
            save.addEventListener('click', function () {
                var saveUrl = "product/updateProduct";
                var productName = $("#productName").val();
                if (productName == null || productName == "") {
                    po.toast('产品名称不能为空', 1);
                    return;
                }
                var productId = $("#productId").val();
                if (productId == null || productId == "") {
                    po.toast('产品编号不能为空', 1);
                    return;
                }
                var area = $("#areaId").val();
                
                var currentPrice = $("#currentPrice").val();
                if (currentPrice == null || currentPrice == "") {
                    po.toast('展示价格不能为空', 1);
                    return;
                }
                var originalPrice = $("#originalPrice").val();
                var content = $("#text1").val();
               
                if (content == null || content == "" || content.length < 10) {
                    po.toast('摘要内容字数太少啦!', 1);
                    return;
                }
                if (treeNodeId == null) treeNodeId = $("#pid").val();
                var params = {
                    "id": idid,
                    //"pictureName": $("#pictureName").val(),
                    "productName": productName,
                    "productId": productId,
                    "area": area,
                    //"texture": $("#texture").val(),
                    //"weight": $("#weight").val(),
                    "currentPrice": currentPrice,
                    "originalPrice": originalPrice,
                    //"keyword": $("#keyword").val(),
                    "content": content,
                    "pid": treeNodeId
                };
                //doHandleResult(saveUrl, params);
                $.getJSON(saveUrl, params, function (result) {
                    po.confirm("提示","确认修改?",
                        function(){
                            //getObjects();
                            window.parent.location.reload(true);
                            layer_close();
                        }
                    );
                    
                });
            });
        });
    </script>

    <script>
        $(function () {
            $("#add_picture").fix({
                float: 'left',
                skin: 'green',
                durationTime: false,
                stylewidth: '220',
                spacingw: 0,
                spacingh: 260,
            });
        });
        $(document).ready(function () {
            //初始化宽度、高度
            $(".widget-box").height($(window).height());
            $(".page_right_style").height($(window).height());
            $(".page_right_style").width($(window).width() - 220);
            //当文档窗口发生改变时 触发  
            $(window).resize(function () {
                $(".widget-box").height($(window).height());
                $(".page_right_style").height($(window).height());
                $(".page_right_style").width($(window).width() - 220);
            });
        });
        /* $(function () {
            var ue = UE.getEditor('editor');
        }); */
        /******树状图********/
        var treeNodeId;
        var setting = {
            view: {
                dblClickExpand: false,
                showLine: false,
                selectedMulti: false
            },
            data: {
                simpleData: {
                    enable: true,
                    idKey: "id",
                    pIdKey: "parentId",
                    rootPId: ""
                }
            },
            callback: {
                beforeClick: function (treeId, treeNode) {
                    var zTree = $.fn.zTree.getZTreeObj("tree");
                    if (treeNode.isParent) {
                        zTree.expandNode(treeNode);
                        return false;
                    } else {
                        demoIframe.attr("src", treeNode.file + ".html");
                        return true;
                    }
                },
                onClick: function (event, treeId, treeNode) {
                    treeNodeId = treeNode.id;
                    //alert("treeNodeId=" + treeNodeId);
                }
            }
        };
        /*================================================================================*/
        $(function () {
            loadZtree();
        });
        var zNodes;
        function loadZtree() {
            var url = "product/productType/findObjects"
            $.getJSON(url, function (result) {
                if (result.state == 1) {
                    $(".type_style").data("data", result.data);
                    zNodes = result.data;
                    //初始化Ztree数据
                    var t = $("#treeDemo");
                    zTree = $.fn.zTree.init(
                        t,
                        setting,
                        zNodes)
                }
                else alert(result.message);
                /* for (var i = 0; i < zNodes.length; i++) {
                    console.log("zNodes[" + i + "]=" + zNodes[i].id);
                } */
            })
        }

        var code;

        function showCode(str) {
            if (!code) code = $("#code");
            code.empty();
            code.append("<li>" + str + "</li>");
        }
        $(document).ready(function () {
            var t = $("#treeDemo");
            t = $.fn.zTree.init(t, setting, zNodes);
            demoIframe = $("#testIframe");
            //demoIframe.bind("load", loadReady);
            var zTree = $.fn.zTree.getZTreeObj("tree");
            //zTree.selectNode(zTree.getNodeByParam("id",'11'));
        });			
    </script>
</body>

</html>